package com.yxl.toolsite.controller;

import com.yxl.toolsite.util.Md5Util;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

@RestController
@RequestMapping("/rest/encrypt")
public class EncryptController {

    @RequestMapping("/md5")
    public String md5encrypt(@RequestParam("inputstr") String inputstr) {
        return Md5Util.getMD5(inputstr);
    }

    public String urlEncode( @RequestParam("inputstr") String inputstr) {
        try {
            return URLEncoder.encode(inputstr,"utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "";
    }
}
